<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class Publish extends BaseRequest
{

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title'     => 'required|string|min:6|max:100',
            'category_id'   => 'required|numeric',
            'body'      => 'required|string|min:30|max:60000'
        ];
    }

    /**
     * 获取验证错误的自定义属性
     *
     * @return array
     */
    public function attributes()
    {
        return [
            'title' => '标题',
            'category_id' => '分类',
            'body' => '内容'
        ];
    }

    /**
     * 获取已定义验证规则的错误消息
     *
     * @return array
     */
    public function messages()
    {
        return [
            'category_id.topic_categories' => '分类错误！'
        ];
    }

}
